package com.scabrand.api;

import com.scabrand.model.Human;
import com.scabrand.service.HumanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author yan
 * @date 2025/8/21
 */
@RestController
@RequestMapping(value = "/api/human",produces = MediaType.APPLICATION_JSON_VALUE)
public class HumanApi {
    private HumanService humanService;
    @Autowired
    public void setHumanService(HumanService humanService) {
        this.humanService = humanService;
    }

    @GetMapping("/id/{id}")
    public ResponseEntity<Map<String, Object>> getHuman(@PathVariable Integer  id){
        Human human = humanService.findHumanById(id);
        return ResponseEntity.ok(Map.of("success", true, "human", human));
    }
}
